<template>
  <div>
    <el-row :gutter="20">
      <el-col :span="6" v-for="item in data" :key="item.id">
        <div class="grid-content bg-purple">
          <h3 class="grtitle">{{ item.title }}</h3>
          <div class="grwarp">
            <div class="xiaoshoudata">
              {{ item.money }}
              <span class="meiyuan" v-if="item.dollorshow">￥</span>
            </div>
            <el-progress
              :percentage="item.target"
              :stroke-width="8"
              :color="item.bgcolor"
              :show-text="false"
            />
            <div class="wanchengdu" :class="{ targetfull: item.target >= 99 }">
              目标完成度{{ item.target }}%
            </div>
          </div>
          <div class="grdata">{{ item.botword }}</div>
        </div>
      </el-col>
      <!-- <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col> -->
    </el-row>
    <div class="bot-index">
      <div class="workerlist">
        <div class="zhouqi" id="main"></div>
        <div class="yuangon zhouqi">
          <div class="banner">
            <div class="bannertitle">员工考勤表</div>
            <el-carousel :interval="4000" type="card" height="159px">
              <el-carousel-item v-for="item in person" :key="item.name">
                <h3 class="medium">
                  <div class="lunbowrap">
                    <div class="perimg">
                      <img src="@/assets/img/person.png" alt="" />
                    </div>
                    <div class="pername">{{ item.name }}</div>
                    <div class="pertime">{{ item.data }}</div>
                    <div class="sign">
                      上班:<span
                        class="inifcardno"
                        :class="{ isred: item.issign !== '正常' }"
                        >{{ item.issign }}</span
                      >
                      <span class="intime">{{ item.intime }}</span>
                    </div>
                    <div class="sign">
                      下班:<span class="outifcard">{{ item.isoutsign }}</span>
                      <span class="outtime">{{ item.outtime }}</span>
                    </div>
                  </div>
                </h3>
              </el-carousel-item>
            </el-carousel>
          </div>
        </div>
      </div>
      <div class="itemrace">
        <div class="hottitle">菜品热度排名</div>
        <div class="hotdishes">
          <li
            class="dishesitem"
            v-for="(item, index) in dashes"
            :key="item.daname"
          >
            <div class="dsrank">{{ index + 1 }}</div>
            <div class="dsname">{{ item.daname }}</div>
            <div class="dsscr">
              <div class="progress" :style="{ width: curwidth(item.hotvalue) }">
                <div class="cssscr"></div>
              </div>
            </div>
            <div class="dsvalue">{{ item.hotvalue }}</div>
          </li>
        </div>
      </div>
    </div>
    <!-- <el-row :gutter="50">
      <el-col :span="16"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="8"><div class="grid-content bg-purple"></div></el-col>
    </el-row> -->
  </div>
</template>
<script lang="ts">
import { defineComponent, onMounted } from "vue";
import * as echarts from "echarts";

export default defineComponent({
  setup() {
    onMounted(() => {
      let main: HTMLElement | null = document.getElementById("main");
      if (main) {
        let myChart = echarts.init(main);
        window.onresize = function () {
          myChart.resize();
        };
        // 绘制图表
        let option = {
          grid: {
            bottom: "30",
          },
          title: {
            text: "周期收入对比",
            y: "10",
            x: "10px",
            textStyle: {
              color: "#fff",
            },
          },
          xAxis: {
            axisLine: {
              lineStyle: {
                color: "#fff",
              },
            },
            type: "category",
            data: [
              "星期一",
              "星期二",
              "星期三",
              "星期四",
              "星期五",
              "星期六",
              "星期日",
            ],
          },
          yAxis: {
            type: "value",
            // data: ["1", "2", "3", "4", "5", "6", "7"],
            axisLabel: {
              textStyle: {
                color: "#fff",
              },
            },
          },
          legend: {
            data: ["本周", "上周"],
            y: "10",
            textStyle: {
              color: "#fff",
              fontSize: "12px",
            },
          },
          series: [
            {
              name: "本周",
              data: [5.2, 5.8, 5.2, 6.1, 6.2, 6.8, 6.6],
              type: "bar",
              color: ["#49ECDA"],
            },
            {
              name: "上周",
              type: "bar",
              color: ["#F6722C"],
              emphasis: {
                focus: "series",
              },
              data: [6.2, 7.3, 6.2, 7.3, 8.3, 7.7, 8.2],
            },
          ],
        };

        myChart.setOption(option);
      }
    });
    // 基于准备好的dom，初始化echarts实例
    function curwidth(val: string | number) {
      let curval = +val / 740;
      return curval * 100 + "%";
    }
    const dashes = [
      {
        daname: "川菜",
        hotvalue: "658",
      },
      {
        daname: "鲁菜",
        hotvalue: "646",
      },
      {
        daname: "粤菜",
        hotvalue: "586",
      },
      {
        daname: "闽菜",
        hotvalue: "556",
      },
      {
        daname: "浙菜",
        hotvalue: "532",
      },
      {
        daname: "苏菜",
        hotvalue: "508",
      },
      {
        daname: "湘菜",
        hotvalue: "468",
      },
    ];
    const person = [
      {
        src: "@/assets/img/person.png",
        name: "陈尾霆",
        data: "2021.12.31 周六",
        issign: "未打卡",
        isoutsign: "正常",
        intime: "09:00",
        outtime: "18:02",
      },
      {
        src: "@/assets/img/person.png",
        name: "赵鹿思",
        data: "2021.12.31 周六",
        issign: "正常",
        isoutsign: "正常",
        intime: "09:00",
        outtime: "18:00",
      },
      {
        src: "@/assets/img/person.png",
        name: "刘亦妃",
        data: "2021.12.31 周六",
        issign: "迟到",
        isoutsign: "正常",
        intime: "09:10",
        outtime: "18:10",
      },
    ];
    const data = [
      {
        id: new Date().getTime(),
        title: "今日销售额",
        money: "76,816",
        target: 87,
        bgcolor: "#F9762D",
        botword: "2021.12.11",
        dollorshow: true,
      },
      {
        id: new Date().getTime(),
        title: "今日利润",
        money: "26,921",
        target: 91,
        bgcolor: "#1BB2A1",
        botword: "详情>",
        dollorshow: true,
      },
      {
        id: new Date().getTime(),
        title: "订单量",
        money: "187",
        target: "100",
        bgcolor: "#4987D2",
        botword: "详情>",
        dollorshow: false,
      },
      {
        id: new Date().getTime(),
        title: "客流量",
        money: "3688",
        target: "100",
        bgcolor: "#826EE1",
        botword: "2021.12.11",
        dollorshow: false,
      },
    ];

    return {
      data,
      person,
      dashes,
      curwidth,
    };
  },
});
</script>

<style lang="scss">
// .el-col {
//   width: 250px;
//   height: 220px;
//   background: #575a71;
//   box-shadow: 0px 5px 8px 0px #040000;
//   border-radius: 20px;
// }
@keyframes scrprocess {
  from {
    width: 0%;
  }
  to {
    width: 100%;
  }
}
.cssscr {
  animation: scrprocess 2s;
  height: 100%;
  background: linear-gradient(90deg, #49ecda, #f6722c);
  border-radius: 8px;
}
.dishesitem .dsrank {
  background-color: #303030;
}
.dishesitem:nth-child(1) .dsrank {
  background-color: #ff4d4d;
}
.dishesitem:nth-child(2) .dsrank {
  background-color: #0052ff;
}
.dishesitem:nth-child(3) .dsrank {
  background-color: #d1703d;
}
.itemrace {
  .hottitle {
    font-size: 18px;
    padding-left: 15px;
    color: #fff;
    padding-top: 10px;
    font-weight: bold;
    margin-bottom: 35px;
  }
  .hotdishes {
    // height: 150px;

    .dishesitem {
      display: flex;
      color: #fff;
      height: 20px;
      font-size: 14px;
      line-height: 20px;
      font-family: MicrosoftYaHei;
      margin-bottom: 27px;
      .dsrank {
        margin-left: 74px;
        margin-right: 6px;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        text-align: center;
      }

      .dsname {
        margin-right: 12px;
      }
      .dsscr {
        margin-right: 7px;
        width: 396px;
        background-color: #8a8c9c;
        position: relative;
        border-radius: 15px;
        .progress {
          position: absolute;
          height: 100%;

          border-radius: 8px;
        }
      }
      .dsvalue {
        color: #fff;
      }
    }
  }
}
.yuangon {
  .banner {
    // height: 185px;
    padding-left: 20px;
    padding-right: 20px;
    .bannertitle {
      color: #fff;
      margin-left: -5px;
      font-size: 18px;
      font-weight: bold;
      padding-top: 5px;
    }
    .el-carousel__indicators {
      display: none;
    }
  }
}

.medium {
  img {
    width: 100%;
  }
  .perimg {
    width: 62px;
    height: 62px;
    margin: 0px auto;
    margin-bottom: 5px;
    margin-top: 5px;
  }
  .pertime {
    font-size: 12px;
    margin: 2px 0px;
  }
  .pername {
    text-align: center;
    height: 20px;
    color: #000;
  }
  .sign {
    color: #111;
    .inifcardno {
      display: inline-block;
      width: 70px;
      color: #22b713;
    }
    .outifcard {
      display: inline-block;
      width: 70px;
      color: #22b713;
    }
    .isred {
      color: red;
    }
    .intime,
    .outtime {
      font-size: 12px;
    }
  }
}

.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  // line-height: 200px;
  margin: 0;
  text-align: center;
}
.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}
.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}

$liheight: 200px;
$double: 420px;
.grid-content {
  font-family: MicrosoftYaHei;
  position: relative;
  .grdata {
    color: #fff;
    position: absolute;
    right: 20px;
    bottom: 10px;
  }
  .grwarp {
    // height: 100px;
    padding-top: 7%;
    text-align: center;
    width: 250px;
    margin: 0 auto;
    // display: flex;
    // flex-direction: column;
    // align-items: center;
    .el-progress-bar__outer {
      width: 150px;
      margin: 0 auto;
      background: #75788a;
    }
    .wanchengdu {
      margin-top: 8px;
      color: #fff;
    }
    .xiaoshoudata {
      color: #f9762d;
      font-size: 35px;
      font-weight: bold;
      .meiyuan {
        font-size: 16px;
      }
    }
    .targetfull {
      color: #34c920;
    }
  }
  .grtitle {
    height: 50px;
    padding-top: 18px;
    color: #fff;
    font-size: 18px;
    padding-left: 25px;
  }
}

.bot-index {
  display: flex;
  width: 100%;
  .workerlist {
    width: 49%;
  }
  .itemrace {
    width: 49%;
    height: $double;
    background: #575a71;
    box-shadow: 0px 5px 8px 0px #040000;
    border-radius: 20px;
    margin-top: 20px;
    margin-left: 30px;
  }
}
.zhouqi {
  width: 100%;
  height: $liheight;
  background: #575a71;
  box-shadow: 0px 5px 8px 0px #040000;
  border-radius: 20px;
  margin-top: 20px;
}
.bg-purple {
  background: #575a71;
}
.grid-content {
  border-radius: 4px;
  min-height: 100px;
  width: 100%;
  height: $liheight;
  box-shadow: 0px 5px 8px 0px #040000;
  border-radius: 20px;
}
</style>
